home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Graphismes / Bitmap / NIH Image 1.59 / Macros / Line Plot->Data < prev    next >
Text File  |  1993-11-03  |  3KB  |  122 lines

  1. macro 'Convert Line Plot to Points [C]';
  2. {
  3. Requires a binary image conatining a black plot on a white
  4. background. Select the plot before running this macro. It may be
  5. necessary to increase Max Measurements in Options.
  6. }
  7. var
  8.   left,top,width,height,i,nPixels,mean,mode,min,max:integer;
  9. begin
  10.   RequiresVersion(1.45);
  11.   Measure;
  12.   GetResults(nPixels,mean,mode,min,max);
  13.   if (histogram[0]+histogram[255])<>nPixels then begin
  14.     PutMessage('This macro only works on binary images.');
  15.     exit;
  16.   end;
  17.   if histogram[0]<histogram[255] then begin
  18.     PutMessage('This macro requires a black plot on a white background.');
  19.     exit;
  20.   end;
  21.   SaveState;
  22.   GetRoi(left,top,width,height);
  23.   if width=0 then begin
  24.     PutMessage('Please select the line plot.');
  25.     exit;
  26.   end;
  27.   Duplicate('Particles');
  28.   i:=0;
  29.   SetForegroundColor(0);
  30.   SetLineWidth(1);
  31.   repeat
  32.     MoveTo(i,0);
  33.     LineTo(i,height);
  34.     i:=i+2;
  35.   until i>width;
  36.   RotateRight(true);
  37.   SetOptions('X-Y Center');
  38.   LabelParticles(false);
  39.   SetParticleSize(1,999999);
  40.   InvertY(false);
  41.   AnalyzeParticles;
  42.   RestoreState;
  43. end;
  44.  
  45.  
  46. macro 'Plot Points [P]';
  47. {
  48. Plots the data points contained in the X and Y results columns. Note
  49. that X and Y are reversed because Analyze Particles scans from top
  50. to bottom, not left to right.
  51. }
  52. var
  53.   xmin,xmax,ymin,ymax,i,xscale,yscale:real;
  54.   width,height,margin,pwidth,pheight:integer;
  55. begin
  56.   SaveState;
  57.   margin:=40;
  58.   width:=500;
  59.   height:=300;
  60.   xmin:=999999;
  61.   xmax:=-999999;
  62.   ymin:=999999;
  63.   ymax:=-999999;
  64.   for i:=1 to rCount do begin
  65.     if rX[i]<xmin then xmin:=rX[i];
  66.     if rX[i]>xmax then xmax:=rX[i];
  67.     if rY[i]<ymin then ymin:=rY[i];
  68.     if rY[i]>ymax then ymax:=rY[i];
  69.   end;
  70.   SetNewSize(width,height);
  71.   SetForeground(255);
  72.   SetBackground(0);
  73.   MakeNewWindow('Plot');
  74.   pwidth:=width-2*margin;
  75.   pheight:=height-2*margin;
  76.   xscale:=pheight/(xmax-xmin);
  77.   yscale:=pwidth/(ymax-ymin);
  78.   SetForeground(255);
  79.   SetBackground(0); 
  80.   MoveTo(margin,margin);
  81.   for i:=1 to rCount do begin
  82.     LineTo(margin+(rY[i]-ymin)*yscale,margin+(rX[i]-xmin)*xscale);
  83.   end;
  84.   MakeRoi(margin,margin,pwidth+1,pheight+2);
  85.   MoveTo(margin,margin);
  86.   LineTo(margin+pwidth,margin);
  87.   MoveTo(margin,margin);
  88.   LineTo(margin,margin+pheight);
  89.   FlipVertical;
  90.   KillRoi;
  91.   SetFont('Geneva');
  92.   SetFontSize(9);
  93.   SetText('Centered');
  94.   MoveTo(margin+4,margin+pheight+12);
  95.   writeln(ymin:1:2);
  96.   MoveTo(margin+pwidth,margin+pheight+12);
  97.   writeln(ymax:1:2);
  98.   SetText('Right Justified');
  99.   MoveTo(margin-2,margin+pheight-5);
  100.   writeln(xmin:1:2);
  101.   MoveTo(margin-2,margin);
  102.   writeln(xmax:1:2);
  103.   RestoreState;
  104. end;
  105.  
  106.  
  107. macro 'Clear Outside [O]'
  108.  {Outline the line plot with the wand tool and then use this macro to}
  109.  {erase everything else.}
  110. begin
  111.   Copy;
  112.   SelectAll;
  113.   Clear;
  114.   RestoreRoi;
  115.   Paste;
  116.   KillRoi;
  117. end;
  118.  
  119.  
  120.  
  121.  
  122.